home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_023 / ver30 / tty / heath / tty.c next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  198 lines

  1. /*
  2.  * Name:    MicroEMACS
  3.  *        Heath H19 display
  4.  * Version:    29
  5.  * Last edit:    10-Feb-86
  6.  * By:        rex::conroy
  7.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  8.  *
  9.  * This code simulates scrolling regions by using the
  10.  * insert line and delete line functions. Should display
  11.  * handling be told about this?
  12.  * This is code is by Rich Ellison. A man always does
  13.  * the support for the terminal he owns.
  14.  */
  15. #include    "def.h"
  16.  
  17. #define    BEL    0x07            /* BEL character.        */
  18. #define    ESC    0x1B            /* ESC character.        */
  19. #define    LF    0x0A            /* Line feed.            */
  20.  
  21. extern    int    ttrow;
  22. extern    int    ttcol;
  23. extern    int    tttop;
  24. extern    int    ttbot;
  25. extern    int    tthue;
  26.  
  27. int    tceeol    =    2;        /* Costs.            */
  28. int    tcinsl    =    11;
  29. int    tcdell    =    11;
  30.  
  31. /*
  32.  * The Heath needs no initialization.
  33.  */
  34. ttinit()
  35. {
  36. }
  37.  
  38. /*
  39.  * The Heath needs no tidy up.
  40.  */
  41. tttidy()
  42. {
  43. }
  44.  
  45. /*
  46.  * Move the cursor to the specified
  47.  * origin 0 row and column position. Try to
  48.  * optimize out extra moves; redisplay may
  49.  * have left the cursor in the right
  50.  * location last time!
  51.  */
  52. ttmove(row, col)
  53. {
  54.     if (ttrow!=row || ttcol!=col) {
  55.         if (row > NROW)
  56.             row = NROW;
  57.         if (col > NCOL)
  58.             col = NCOL;
  59.         ttputc(ESC);
  60.         ttputc('Y');
  61.         ttputc(row+' ');
  62.         ttputc(col+' ');
  63.         ttrow = row;
  64.         ttcol = col;
  65.     }
  66. }
  67.  
  68. /*
  69.  * Erase to end of line.
  70.  */
  71. tteeol()
  72. {
  73.     ttputc(ESC);
  74.     ttputc('K');
  75. }
  76.  
  77. /*
  78.  * Erase to end of page.
  79.  */
  80. tteeop()
  81. {
  82.     ttputc(ESC);
  83.     ttputc('J');
  84. }
  85.  
  86. /*
  87.  * Make a noise.
  88.  */
  89. ttbeep()
  90. {
  91.     ttputc(BEL);
  92.     ttflush();
  93. }
  94.  
  95. /*
  96.  * Insert nchunk blank line(s) onto the
  97.  * screen, scrolling the last line on the
  98.  * screen off the bottom. This is done with
  99.  * a cluster of clever insert and delete commands,
  100.  * because there are no scroll regions.
  101.  */
  102. ttinsl(row, bot, nchunk)
  103. {
  104.     register int    i;
  105.  
  106.     if (row == bot) {        /* Case of one line insert is     */
  107.         ttmove(row, 0);        /*    special            */
  108.         tteeol();
  109.         return;
  110.     }
  111.     ttmove(1+bot-nchunk, 0);
  112.     for (i=0; i<nchunk; i++) {    /* For all lines in the chunk    */
  113.         ttputc(ESC);        /* DEL current line, anything    */
  114.         ttputc('M');        /* below moves up.        */
  115.     }
  116.     ttmove(row, 0);
  117.     for (i=0; i<nchunk; i++) {    /* For all lines in the chunk    */
  118.         ttputc(ESC);        /* INS before current line,    */
  119.         ttputc('L');        /* sliding stuff down.        */
  120.     }
  121.     ttrow = row;            /* End up on current line    */
  122.     ttcol = 0;
  123. }
  124.  
  125. /*
  126.  * Delete nchunk line(s) "row", replacing the
  127.  * bottom line on the screen with a blank
  128.  * line. This is done with a crafty sequences
  129.  * of insert and delete line; there is no scroll
  130.  * region on the Heath. The presence of the
  131.  * echo area makes a boundry condition
  132.  * go away.
  133.  */
  134. ttdell(row, bot, nchunk)
  135. {
  136.     register int    i;
  137.  
  138.     if (row == bot) {        /* One line special case    */
  139.         ttmove(row, 0);
  140.         tteeol();
  141.         return;
  142.     }
  143.     ttmove(row, 0);
  144.     for (i=0; i<nchunk; i++) {    /* For all lines in chunk    */
  145.         ttputc(ESC);        /* DEL top line, lines below    */
  146.         ttputc('M');        /* all move up.            */
  147.     }
  148.     ttmove(1+bot-nchunk,0);
  149.     for (i=0; i<nchunk; i++) {    /* For all lines in chunk    */
  150.         ttputc(ESC);        /* INS line before botton,    */ 
  151.         ttputc('L');        /* all lines move down.        */ 
  152.     }
  153.     ttrow = bot-nchunk;
  154.     ttcol = 0;
  155. }
  156.  
  157. /*
  158.  * No-op.
  159.  */
  160. ttwindow(top, bot)
  161. {
  162. }
  163.  
  164. /*
  165.  * No-op.
  166.  */
  167. ttnowindow()
  168. {
  169. }
  170.  
  171. /*
  172.  * Set display color on Heath. Normal
  173.  * video is text color. Reverse video is used for
  174.  * the mode line. Rich knew the sequences for the
  175.  * Heath by heart.
  176.  */
  177. ttcolor(color)
  178. register int    color;
  179. {
  180.     if (color != tthue) {
  181.         if (color == CTEXT) {        /* Normal video.    */
  182.             ttputc(ESC);
  183.             ttputc('q');
  184.         } else if (color == CMODE) {    /* Reverse video.    */
  185.             ttputc(ESC);
  186.             ttputc('p');
  187.         }
  188.         tthue = color;
  189.     }
  190. }
  191.  
  192. /*
  193.  * No-op.
  194.  */
  195. ttresize()
  196. {
  197. }
  198.